﻿#include "MainWindow.h"

#include "Python.h"
#include <QDebug>

#include "./ui_MainWindow.h"
#include "Test0.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::MainWindow) {
  ui->setupUi(this);

  // 初始化python解释器,C/C++中调用Python之前必须先初始化解释器
  Py_Initialize();
}

MainWindow::~MainWindow() {
  delete ui;

  // 撤销Py_Initialize()
  Py_Finalize();
}

void MainWindow::on_btnRunScript_clicked() {
  auto rawData{ui->textScript->toPlainText().toStdString()};
  PyRun_SimpleString(rawData.c_str());
}

void MainWindow::on_btnRunQt_clicked() {
  auto item = Test0::Content();
  item->addOne();
  auto data = item->data();
  qDebug() << data;
}
